package shapes;

import java.util.HashMap;

public final class ShapesFactory {
	private static volatile ShapesFactory instance = null;
	private static HashMap<String, Shapes> registry = new HashMap<String, Shapes>();
	
	private  ShapesFactory()
	{
		super();
	}
	
	public final static ShapesFactory getInstance()
	{
		if (ShapesFactory.instance == null)
		{
			synchronized(ShapesFactory.class) {
              if (ShapesFactory.instance == null) {
            	  ShapesFactory.instance = new ShapesFactory();
              }
            }
         }
         return ShapesFactory.instance;
	}
	
	public Shapes makeSquare(){
		return new Square();
	}
	
	public Shapes makeSquare(int x, int y, int side){
		return new Square(x,y,side);
	}
	
	public Shapes makeCircle(){
		return new Circle();
	}
	
	public Shapes makeCircle(int x, int y, int radius){
		return new Circle(x,y,radius);
	}
	
	public static void registerShape(String name, Shapes s){
		registry.put(name, s);
	}
	
	public Shapes createShape(String name) {
		return registry.get(name).createShape();
	}
	
}
